package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.ProductStore;
import com.example.demo.entity.PurchaseOrder;
import com.example.demo.service.ProductStoreService;
import com.example.demo.mapper.ProductStoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 18364
* @description 针对表【product_store】的数据库操作Service实现
* @createDate 2025-02-08 15:11:44
*/
@Service
public class ProductStoreServiceImpl extends ServiceImpl<ProductStoreMapper, ProductStore>
    implements ProductStoreService{
    @Autowired
    ProductStoreMapper productStoreMapper;

    @Override
    public ProductStore select(String storeNumber, String orderNumber) {
        QueryWrapper<ProductStore> queryWrapper=new QueryWrapper<>();
        if(storeNumber!=null){
            queryWrapper.eq("storeNumber",storeNumber);
        }
        if(orderNumber!=null){
            queryWrapper.eq("orderNumber",orderNumber);
        }
        queryWrapper.orderByDesc("storeTime");
        List<ProductStore> resultList = productStoreMapper.selectList(queryWrapper);
        if (!resultList.isEmpty()) {
            return resultList.get(0); // 这里返回结果列表的第一条记录
        } else {
            return null;
        }
    }

    @Override
    public Integer deletById(Integer id) {
        return productStoreMapper.deleteById(id);
    }
}




